/*
 *  bodypart.h
 *  bgsubtraction
 *
 *  Created by a1gucis on 4/5/09.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */
#ifndef BODYPART_H
#define BODYPART_H
#define BG_LABEL_MATRIX_SIZE 30
#include "systeminclude.h"
#include "em.h"
#include "clusters.h"
#include "clusterfusion.h"
#include "utils.h"
#include "kmeans.h"
#include <iostream.h>
#include <algorithm>
#include <vector>
using namespace std;

class BodyPart {
protected:
	EM *em;
	KMeans *kmeans;
	int bgLabel;
	int nClusters;
	int mopCloseIterations;
	IplImage *originalImage, *labeledImage;
	IplImage *trainImage;
	ClusterFusion *clusterFusion;
	
	//determine the background label of the labeledImage using the neighbourhood parameter
	int findBgLabel(int ); 	
	
	//checks if the label at row col is part of a blob. Neighbourhood parameter corresponds to matrix size.
	bool isBlob(int row, int col, int neighbourhood);
					  
public:
	BodyPart(int );
	~BodyPart();
	void train(bool); //train the EM, input: boolean value, whether image size has changed or not
	void setLabels(); //create the labeled image using em algorithm
	void setBgLabel(int label); //sets the background label. Testing purposes only
	void setOriginalImage(IplImage *); 
	void setTrainImage(IplImage *);
	int getBgLabel();
	IplImage *getLabeledImage();
	IplImage *getOriginalImage();
	
	//test purposes
	void test();
	
};


#endif